include("shared.lua");
AddCSLuaFile("cl_init.lua");
AddCSLuaFile("shared.lua");
-- Setting up all the different properties of our melon.
ENT.Delay = 1.4;
ENT.Healthlol = 500;
ENT.FiringRange = 500;
ENT.NoMoveRange = 20;
ENT.DeathRadius = 500;
ENT.DeathMagnitude = 75;
ENT.MovingForce = 25;
ENT.MelonModel = "models/props_wasteland/laundry_washer003.mdl";

-- Now we tell the base class to set up the melon. Pay attention - the variables must be defined BEFORE calling Setup().
function ENT:Initialize()
	self:Setup();
	self.Entity:SetMaterial(nil);
end

--No attacking or other thoughts function - this is a special warmelon, and as such, we want to override Think().
function ENT:DoAttacks ()
	local entz = ents.FindByClass("info_target");
	for k, v in pairs(entz) do
		if v.Warmelon then
			if (v:GetPos():Distance(self.Entity:GetPos())<self.FiringRange && v:GetParent():GetTable().Team == self.Team) then
			     if v:GetParent():GetTable().Healthlol ~= nil && v:GetParent():GetTable().Healthlol < v:GetParent():GetTable().Maxlol then
					local angle = v:GetParent():GetPos() - self.Entity:GetPos();
					v:GetParent():GetTable().Healthlol = v:GetParent():GetTable().Healthlol+2;
						local fx = EffectData();
						fx:SetOrigin(v:GetPos());
						util.Effect("johnny_healing", fx);
					if (v:GetParent():GetTable().Healthlol>v:GetParent():GetTable().Maxlol/5 && v:GetParent():GetTable().trail) then
						v:GetParent():GetTable().trail:Remove();
						v:GetParent():GetTable().trail = nil;
					end
				 elseif v:GetParent():GetTable().health ~= nil && v:GetParent():GetTable().health < v:GetParent():GetTable().maxhealth then
				   v:GetParent():GetTable().health = v:GetParent():GetTable().health+2;    
if v:GetParent():GetTable().health > (v:GetParent():GetTable().maxhealth * 0.5) then

     if (v.Team == 1) then
		v:GetParent():SetColor (255, 0, 0, 255);
	end
	if (v.Team == 2) then
		v:GetParent():SetColor (0, 0, 255, 255);
	end
	if (v.Team == 3) then
		v:GetParent():SetColor (0, 255, 0, 255);
	end
	if (v.Team == 4) then
		v:GetParent():SetColor (255, 255, 0, 255);
	end
	if (v.Team == 5) then
		v:GetParent():SetColor (255, 0, 255, 255);
	end
	if (v.Team == 6) then
		v:GetParent():SetColor (0, 255, 255, 255);
	end
end
end
			end
		end
	end
end
